import React, { Component } from 'react';

import HelloWorld3 from './HelloWorld3';

interface Loading {
  loading: boolean;
}

function HelloWorldHOC<P>(WrappedComponent: React.ComponentType<P>) {
  return class extends Component<P & Loading> {
    render() {
      const { loading, ...props } = this.props;
      return loading ? <div>loading...</div> : <WrappedComponent {...props as P}/>;
    }
  };
}

export default HelloWorldHOC(HelloWorld3);
